package com.ljw.spring.annotation.selector;

import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @FileName MyImportSelector
 * @Description TODO @Import(value = {Color.class, Car.class, MyImportSelector.class})：向IOC容器中组团导入组件
 * @Author ljw
 * @Date 2021/2/1 23:41
 * @Version 1.0
 */
public class MyImportSelector implements ImportSelector {
    /**
     * 返回需要导入的组件的 全类名数组
     * @param importingClassMetadata 当前标注@Import注解的类的 所有注解（包括@Import注解）信息
     * @return
     */
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        System.out.println("向IOC容器组团导入组件数组");
        //返回值至少为空数组，不能为null
        return new String[]{"com.ljw.spring.annotation.bean.Boat","com.ljw.spring.annotation.bean.Bike"};
    }
}
